//
//  SGHomeListModel.swift
//  songguo
//
//  Created by 潘传洲 on 16/6/11.
//  Copyright © 2016年 pcz. All rights reserved.
//

import UIKit

// 活动类型
enum ModelType : Int{
    case Article = 0
    case Activity = 1
}

class SGHomeListModel: NSObject {
    var type: ModelType?
    var ct: Double?
    var article : SGArticleModel?
    var activity : SGActivityModel?
    
    class func homeListModels(array : [[String : AnyObject]]) -> [SGHomeListModel] {
        var homeListModels = [SGHomeListModel]()
        
        for dict in array {
            
            let model = SGHomeListModel()
            
            model.type = ModelType.init(rawValue: (dict["type"] as? Int)!)
            model.ct = dict["ct"] as? Double
            if model.type == ModelType.Activity {
                model.activity = SGActivityModel.initWithDict(dict["activity"] as! [String : AnyObject])
            }else{
                model.article = SGArticleModel.initWithDict(dict["article"] as! [String : AnyObject])
            }
            
            homeListModels.append(model)
        }
        
        return homeListModels
    }

    
}
